<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>驾驶员注册</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="lib/layui-v2.5.5/css/layui.css" media="all">
</head>
<body>
 <div style="width: 60%;margin: auto;">
 	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
	  <legend>注册</legend>
	</fieldset>
	<form class="layui-form" action="">
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 用户名</label>
	    <div class="layui-input-block">
	      <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入用户名" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 密码</label>
	    <div class="layui-input-block">
	      <input type="password" id="password" name="password" lay-verify="required"  autocomplete="off" placeholder="请输入密码" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 确认密码</label>
	    <div class="layui-input-block">
	      <input type="password" name="password_2" lay-verify="password_2|required"  autocomplete="off" placeholder="请输入确认密码" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 姓名</label>
	    <div class="layui-input-block">
	      <input type="text" name="name" lay-verify="required"  autocomplete="off" placeholder="请输入用姓名" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 性别</label>
	    <div class="layui-input-block">
	      	<input type="radio" name="sex" value="0" title="男" checked>
			<input type="radio" name="sex" value="1" title="女">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 年龄</label>
	    <div class="layui-input-block">
	      <input type="number" name="age" lay-verify="required" autocomplete="off" placeholder="请输入年龄" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 电话号码</label>
	    <div class="layui-input-block">
	      <input type="text" name="phone" lay-verify="required"  autocomplete="off" placeholder="请输入电话号码" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 电话驾龄</label>
	    <div class="layui-input-block">
	      <input type="number" name="dage" lay-verify="required"  autocomplete="off" placeholder="请输入驾龄" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 车牌号 </label>
	    <div class="layui-input-block">
	      <input type="text" name="carNo" lay-verify="required"  autocomplete="off" placeholder="请输入车牌号" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 车型 </label>
	    <div class="layui-input-block">
		    <select name="carType" lay-filter="aihao">
		        <option value=""></option>
		        <option value="小型车">小型车</option>
		        <option value="微型车">微型车</option>
		        <option value="紧凑车型">紧凑车型</option>
		        <option value="中等车型">中等车型</option>
		        <option value="高级车型">高级车型</option>
		        <option value="豪华车型">豪华车型</option>
		        <option value="三厢车型">三厢车型</option>
		        <option value="CDV车型">CDV车型</option>
		        <option value="MPV车型">MPV车型</option>
		        <option value="SUV">SUV</option>
		      </select>
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 颜色</label>
	    <div class="layui-input-block">
	      <input type="text" name="title" lay-verify="required"  autocomplete="off" placeholder="请输入颜色" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <label class="layui-form-label"> 爱好</label>
	    <div class="layui-input-block">
	      <input type="text" name="hobby" autocomplete="off" placeholder="请输入爱好" class="layui-input">
	    </div>
	  </div>
	  <div class="layui-form-item">
	    <div class="layui-input-block">
	      <button type="submit" class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
	      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
	      <button type="button" class="layui-btn layui-btn-primary" onclick="login()">去登录</button>
	    </div>
	  </div>
	</form>
</div>
<script src="lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script type="text/javascript" src="lib/jquery-3.4.1/jquery-3.4.1.min.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script>
var layer,form;
layui.use(['layer','form'], function () {
	layer = layui.layer;
	form= layui.form;
	form.verify({
		password_2:function(value,item){
			var password = $("#password").val();
			if(password !=value){
				return "确认密码不一致";
			}
			return '';
		}
	});
	//监听提交
  	form.on('submit(formDemo)', function(data){
//     	layer.msg(JSON.stringify(data.field));
    	$.post("/register",data.field,function(obj){
    		layer.alert(obj.message,function(){
    			if(obj.success){login();}
    		});
    	},"json");
    	return false;
  	});
});
var login = function(){
	window.location.href = "login.html";
}
var register = function(){
	window.location.href = "register.html";
}
</script>
</body>
</html>